<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/js-test.js"></script>
</head>
<body>
<div id="mainFrameText">This test checks that long press to select text focuses the pressed frame.</div>
<script>

function longPressElement(el) {
    x = el.offsetLeft + el.offsetWidth / 2;
    y = el.offsetTop + el.offsetHeight / 2;
    eventSender.gestureLongPress(x, y);
}

var framesLoaded = 0;
function frameLoaded() {
  framesLoaded++;
  if (framesLoaded == 2)
    runTest();
}

function runTest()
{
    if (window.testRunner)
        testRunner.dumpAsText();

    if (!window.eventSender)
        return;

    if (eventSender.gestureLongPress) {
        mainFrameText = document.getElementById("mainFrameText");
        frame1 = document.getElementById("frame1");
        frame2 = document.getElementById("frame2");

        longPressElement(frame1);
        shouldBeTrue("document.activeElement == frame1");
        longPressElement(frame2);
        shouldBeTrue("document.activeElement == frame2");
        longPressElement(mainFrameText);
        shouldBeTrue("document.activeElement == document.body");
    } else {
        debug("gestureLongPress not implemented by this platform");
    }
}
</script>
<iframe id="frame1" onload="frameLoaded()" src="data:text/html,
<html>
<body>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum posuere ipsum. Sed laoreet porttitor tortor ut sollicitudin. Quisque eu arcu in magna ornare pretium. In hac habitasse platea dictumst. Morbi vitae blandit mi. Phasellus pellentesque consequat leo, at auctor ligula tempus sed. Aenean magna mi, suscipit vitae auctor non, luctus a sem. Morbi nec purus massa. In hac habitasse platea dictumst. Vivamus dictum justo eu diam suscipit porttitor. Donec ipsum urna, laoreet in feugiat sit amet, imperdiet ac lorem. Pellentesque massa odio, accumsan nec varius sed, tristique ac felis. Phasellus quis mi ac mauris venenatis malesuada. Quisque placerat bibendum enim, eget tempor ipsum molestie quis. Nam eget purus lorem, a dignissim enim.
</body>
</html>
"></iframe>
<iframe id="frame2" onload="frameLoaded()" src="data:text/html,
<html>
<body>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum posuere ipsum. Sed laoreet porttitor tortor ut sollicitudin. Quisque eu arcu in magna ornare pretium. In hac habitasse platea dictumst. Morbi vitae blandit mi. Phasellus pellentesque consequat leo, at auctor ligula tempus sed. Aenean magna mi, suscipit vitae auctor non, luctus a sem. Morbi nec purus massa. In hac habitasse platea dictumst. Vivamus dictum justo eu diam suscipit porttitor. Donec ipsum urna, laoreet in feugiat sit amet, imperdiet ac lorem. Pellentesque massa odio, accumsan nec varius sed, tristique ac felis. Phasellus quis mi ac mauris venenatis malesuada. Quisque placerat bibendum enim, eget tempor ipsum molestie quis. Nam eget purus lorem, a dignissim enim.
</body>
</html>
"></iframe>
</body>
</html>
